#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <float.h>
#include <iostream>
#include <chrono>
#include <vector>
using namespace std;
typedef chrono::high_resolution_clock Clock;

#define SIZE 1024 * 1024 * 256

// https://blog.csdn.net/synapse7/article/details/19157801

int main()
{
    vector<double> db2(SIZE, DBL_MAX);
    auto startTime = Clock::now();
    db2.assign(SIZE, DBL_MAX);
    // for(int i=0; i<SIZE; i++)
    // printf("%.3e ", db[i]);
    // printf("\n%.3e\n", DBL_MAX);

    // int *im = (int *)(SIZE * sizeof(int));
    // memset(im, -1, SIZE * sizeof(int));
    // for(int i=0; i<SIZE; i++)
    // printf("%d ", im[i]);
    auto endTime = Clock::now();
    auto compTime = chrono::duration_cast<chrono::microseconds>(endTime - startTime);
    cout << "Computing time=" << compTime.count() / 1000 << " ms" << endl;

    double *db = (double *)malloc(SIZE * sizeof(double));
    startTime = Clock::now();
    memset(db, 127, SIZE * sizeof(double));
    endTime = Clock::now();
    compTime = chrono::duration_cast<chrono::microseconds>(endTime - startTime);
    cout << "Computing time=" << compTime.count() / 1000 << " ms" << endl;

    delete (db);
    // delete (im);
    return 0;
}